<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MacroParse
 *
 * @author yanr
 */
class MacroParse {
    //put your code here
    protected $subParses;
    static protected $instance;
    
    static public function getInstance()
    {
        IF( is_null(self::$instance) ) self::$instance = new MacroParse;
        RETURN self::$instance;
    }
    
    public function __construct() {
        $this->subParses = array();
    }
    
    public function parseInfo( $info )
    {
        FOR( $i = 0; $i < count( $this->subParses ); $i++ )
            IF( isset ( $this->subParses[$i] ) )
                $this->subParses[$i]->parseInfo($info);
    }

    protected function addSubParse( $parseClassName )
    {
        Logger::trace( "ADD Sub Parse:".$parseClassName );
        $parseClassReflection = new ReflectionClass( $parseClassName );
//        IF( $parseClassReflection->hasMethod( "getInstance" ) )
//        {
//            $reflectionMethod = $parseClassReflection->getMethod( "getInstance" );
//            //IF( $reflectionMethod->isStatic() )
//            //    array_push( $this->subParses, $reflectionMethod->invoke( null ) );
//            
//        }
//        ELSE
//        {
            $refInstance = $parseClassReflection->newInstance();
            array_push( $this->subParses, $refInstance );
//        }
    }
}

?>
